//
//  ThemeCell.m
//  123
//
//  Created by Wang on 14/11/19.
//  Copyright (c) 2014年 Wang. All rights reserved.
//

#import "ThemeCell.h"

@implementation ThemeCell

- (void)dealloc
{
    [_titleLabel release];
    [_upLabel release];
    [_downImage release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self addObserver:self forKeyPath:@"model" options:NSKeyValueObservingOptionNew context:nil];
        

        self.titleLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
        [_titleLabel setTintColor:[UIColor blackColor]];
        [_titleLabel setFont:[UIFont systemFontOfSize:15]];
        [_titleLabel setTextAlignment:NSTextAlignmentCenter];
        [self addSubview:_titleLabel];
        [_titleLabel setBackgroundColor:[UIColor blueColor]];

        self.upLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
        [_upLabel setTintColor:[UIColor blackColor]];
        [_upLabel setFont:[UIFont systemFontOfSize:12]];
        [_upLabel setNumberOfLines:0];
        [_upLabel sizeToFit];
        [self addSubview:_upLabel];
        [_upLabel setBackgroundColor:[UIColor yellowColor]];

        self.downImage = [[[UIImageView alloc] initWithFrame:CGRectZero] autorelease];
        [_downImage setBackgroundColor:[UIColor orangeColor]];
        [self addSubview:_downImage];
        
        
        
    }
    return self;
}
#pragma mark - 监听
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if ([keyPath isEqualToString:@"model"]) {
        
    }
}






- (void)layoutSubviews
{
    [super layoutSubviews];
    
    
    [_titleLabel setFrame:CGRectMake(0, 10, self.frame.size.width, self.frame.size.height / 7)];
    [_upLabel setFrame:CGRectMake(0, _titleLabel.frame.size.height, self.frame.size.width, _titleLabel.frame.size.height)];
    [_downImage setFrame:CGRectMake(0, _titleLabel.frame.size.height + _upLabel.frame.size.height + 5, self.frame.size.width, self.frame.size.height - _titleLabel.frame.size.height - _upLabel.frame.size.height)];
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
